//1.引入样式表
//公用样式 
require('../../assets/css/index.less');
require('../../assets/fonts/iconfont.css');

// 引入weUI
//引入样式
require('../../lib/weui/weui.css');
//引入js库
let weui = require('../../lib/weui/weui.js');

console.log(weui);

// 当前页面样式
require('./my.less')

//2.引入工具函数 utils
const dom = require('../../utils/dom');
const https = require('../../utils/https');
const local = require('../../utils/local');

// 3.当前页面的js
dom.ready(function () {
    //加载底部菜单
    dom.bMenu('my')

    //获取个人信息
    function getUserInfo() {
        https.get('/api/user/info', function (res) {
            //解构赋值
            let { errno, data } = res;
            //判定
            if (errno == 0) {
                //1.把最新数据渲染到我的页面中 
                dom.getEle('#headPic').src = 'http://fitness.h5.itsource.cn:3701' + data.imgUrl;
                dom.getEle('#nickName').innerHTML = data.nickName;
                dom.getEle('#signTxt').innerHTML = data.sign;

                //2.保存用户信息,在个人资料中再次渲染
                local.set('userData', data)
            }
        })
    }

    //当页面加载时就获取当前用户信息
    getUserInfo();


    
})